{include file="public/head" /}
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header layui-bg-blue">
        <div class="layui-logo"><a href="/admin/Index/index" style="color: #fff;font-size: 20px">学校宿舍管理系统</a></div>
        <!-- 头部按钮 -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a>{$username}</a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;" id="loginOut">注销</a>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll layui-bg-cyan">
            <!-- 左侧导航区域 -->
            <ul class="layui-nav layui-nav-tree layui-bg-cyan" lay-filter="test" >
                <li class="layui-nav-item"><a href="javascript:;" onclick="openapp('/admin/Index/center')">首页</a></li>
                <!--admin登录不能办理入住和退宿登记-->
                {neq name="$id" value="1"}
                    <li class="layui-nav-item"><a href="javascript:;" onclick="openapp('/admin/Student/checkIn')">入住办理</a></li>
                    <li class="layui-nav-item"><a href="javascript:;" onclick="openapp('/admin/Student/checkOut')">退宿办理</a></li>
                {/neq}
                <li class="layui-nav-item">
                    <a href="javascript:;">基础信息管理</a>
                    <dl class="layui-nav-child">
                        {eq name="$id" value="1"}
                        <dd><a href="javascript:;" onclick="openapp('/admin/User/index')">宿管用户管理</a></dd>
                        <dd><a href="javascript:;" onclick="openapp('/admin/Building/index')">宿舍楼管理</a></dd>
                        {/eq}
                        <dd><a href="javascript:;" onclick="openapp('/admin/Dormitory/index')">宿舍管理</a></dd>

                    </dl>
                </li>
                <li class="layui-nav-item"><a href="javascript:;" onclick="openapp('/admin/Index/changePassword')">修改密码</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <iframe src="{:url('admin/Index/center')}" style="width:100%;height: 100%;overflow: auto" frameborder="no"
                scrolling="no" class="appiframe"></iframe>
    </div>
</div>
<script>
    layui.use('element', function(){
        var element = layui.element;
    });
    $(function(){
        //注销按钮监听点击事件
        $("#loginOut").on("click",function(){
            $.ajax({
                url:"{:url('admin/Login/loginOut')}",
                type:"get",
                success:function (res) {
                    console.log(res);
                    if(res.code==1){
                        layui.use('layer', function(){
                            var layer = layui.layer;
                            layer.msg('注销成功',{time: 1000});
                            setTimeout(function () {
                                window.location.href = '/admin/Login/index';
                            },1000);
                        });
                    }
                }
            });
        });

    });
    //切换iframe
    function openapp(url) {
        $("iframe").attr("src",url);
    }
</script>
</body>
</html>